package cn.semyes.ylipfilter.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.semyes.ylipfilter.dao.master.ExcludeIpDao;
import cn.semyes.ylipfilter.entity.ExcludeIpEntity;
import cn.semyes.ylipfilter.service.ExcludeIpService;

@Service
public class ExcludeIpServiceImpl implements ExcludeIpService {
	
	private ExcludeIpEntity excludeIpEntity;
	
	@Autowired
	public ExcludeIpDao excludeIpDao;

	@Override
	public List<ExcludeIpEntity> getExcludeIp(String domain) {
		// TODO Auto-generated method stub
//		excludeIpDao.selectByDomain(domain);
		return excludeIpDao.selectByDomain(domain);
	}

	@Override
	public void saveExcludeIp(String domain, String ip) {
		// TODO Auto-generated method stub
		excludeIpEntity = new ExcludeIpEntity();
		excludeIpEntity.setDomain(domain);
		excludeIpEntity.setIp(ip);
		excludeIpDao.save(excludeIpEntity);
	}

	@Override
	public int deleteByDomainAndIp(String domain, String ip) {
		// TODO Auto-generated method stub
		excludeIpEntity = new ExcludeIpEntity();
		excludeIpEntity.setDomain(domain);
		excludeIpEntity.setIp(ip);
		return excludeIpDao.deleteByDomainAndIp(excludeIpEntity);
	}

	@Override
	public ExcludeIpEntity getIpExist(String domain, String ip) {
		// TODO Auto-generated method stub
		excludeIpEntity = new ExcludeIpEntity();
		excludeIpEntity.setDomain(domain);
		excludeIpEntity.setIp(ip);
		return excludeIpDao.selectByDomainAndIp(excludeIpEntity);
	}

	@Override
	public int deleteAll(String domain) {
		// TODO Auto-generated method stub
		return excludeIpDao.deleteAll(domain);
	}
	
	
}
